package cn.lili.controller;

import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.system.client.UrbanVipClient;
import cn.lili.modules.system.entity.dto.VipDto;
import cn.lili.modules.system.entity.dto.VipPageDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/urban-substation/vip")
@Api(tags = "城市站点会员管理")
public class UrbanVipController {
    @Autowired
    private UrbanVipClient vipClient;

    @ApiModelProperty(value = "会员列表")
    @PostMapping("/list")
    public ResultMessage<Object> getVipList(@RequestBody VipPageDto dto){
        AuthUser currentUser = UserContext.getCurrentUser();
        dto.setLoginId(currentUser.getId());
        dto.setExtendId(currentUser.getExtendId());
        return ResultUtil.data(vipClient.getVipList(dto));
    }

    @ApiModelProperty(value = "会员冻结")
    @GetMapping("/freeze")
    public ResultMessage<Object> vipFreeze(String id){
        vipClient.vipFreeze(id);
        return ResultUtil.success();
    }

    @ApiModelProperty(value = "会员解冻")
    @GetMapping("/unfreeze")
    public ResultMessage<Object> vipUnfreeze(String id){
        AuthUser currentUser = UserContext.getCurrentUser();
        vipClient.vipUnfreeze(id);
        return ResultUtil.success();
    }

}
